﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NPOI.SS.UserModel;
using NPOI.HPSF;
using NPOI.HSSF.UserModel;
using System.IO;

namespace WorkTimePrj
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HSSFWorkbook hssfworkbook2 = new HSSFWorkbook();

            ////create a entry of DocumentSummaryInformation
            DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
            dsi.Company = "NPOI Team";
            hssfworkbook2.DocumentSummaryInformation = dsi;

            ////create a entry of SummaryInformation
            SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
            si.Subject = "NPOI SDK Example";
            hssfworkbook2.SummaryInformation = si;

            //here, we must insert at least one sheet to the workbook. otherwise, Excel will say 'data lost in file'
            //So we insert three sheet just like what Excel does
            ISheet sheet = hssfworkbook2.CreateSheet("Sheet1");


            ((HSSFSheet)hssfworkbook2.GetSheetAt(0)).AlternativeFormula = false;
            ((HSSFSheet)hssfworkbook2.GetSheetAt(0)).AlternativeExpression = false;

             
            IRow header = sheet.CreateRow(0);
            ICell cell = header.CreateCell(0);
            cell.SetCellValue("项目代码");

            FileStream fd = new FileStream("e:\\2.xls", FileMode.Create);
            hssfworkbook2.Write(fd);
            fd.Close();
          
        }
    }
}